package com.zhuimeng.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Boolean logined = (Boolean) request.getSession().getAttribute("logined");
        if (logined==null || logined==false){
            response.sendRedirect("http://localhost:8080");
            return false;
        }
        return logined;
    }
}
